public class Flashlight {

    BatteryBehavior battery;
    private int energyLight;

    void changeBattery(BatteryBehavior battery) {
        this.battery = battery;
    }

    void doLight(int energyLight) {
        int capacitance = battery.getCapacitance();
        while (capacitance > 0) {
            capacitance = battery.getCapacitance() - energyLight;
            battery.setCapacitance(capacitance);
            if (capacitance > 0) {
                System.out.println("I light and battery energy="
                        + battery.getCapacitance());
            } else {
                System.out.println("Please insert a new battery");
            }

        }
    }

    public int getEnergyLight() {
        return energyLight;
    }

    public void setEnergyLight(int energyLight) {
        this.energyLight = energyLight;
    }

}
